<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Tymon\JWTAuth\Facades\JWTAuth;
use Illuminate\Support\Facades\DB;
use App\Jobs\DelayOrder;
class OrderController extends Controller
{


    protected  $redis = '';
    protected  $key = 'order_list';

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Contracts\Support\Renderable
     */
    public function index()
    {
        $user_id = 888;
        $goods_id = rand();
        $order = DB::insert('insert into mall_order ( user_id,order_id) values (?, ?)', [$user_id, $goods_id]);
        $id = DB::getPdo()->lastInsertId();

        if($id){
            // 半小时之后 不付款 取消订单状态加入延时队列
            $this->dispatch(new DelayOrder($id));
        }else{
        }
    }

}